package com.dyz.leetcode;

public class FindTargetSumWays494 {
    private int count=0;
    public int findTargetSumWays(int[] nums, int target) {
        dfs(nums, target, 0, 0);
        return count;
    }
    public void dfs(int[]nums, int target, int start, int sum){
        if(start==nums.length){
            if(sum==target){
                count++;
            }
            return;
        }
        dfs(nums, target, start+1, sum+nums[start]);
        dfs(nums, target, start+1, sum-nums[start]);
    }
}
